// pages/paySuccessful/paySuccessful.js
const app = getApp()
var api = require('../../utils/api.js')
var util = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if (options.pickup_code){
      var newArr = [];
      var pickupCode = options.pickup_code;
      for (var i = 0; i < pickupCode.length; i++) {
        var item = pickupCode.substr(i, 1);
        newArr.push(item)
      }

      this.setData({
        pickup_code: newArr
      })
    }

    

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    // this.data.items = wx.getStorageSync('orderList');
    this.setData({
      items: wx.getStorageSync('orderList'),
      buy_type: wx.getStorageSync('buy_type')
    })
    var items = this.data.items;
    var total_price = 0;
    for (var i = 0; i < items.length; i++) {
      total_price = (total_price/1 + items[i].total / 1).toFixed(2);
    }
    this.setData({
      total_price: total_price,
      length: items.length
    })
  },
  complete:function(){
    wx.switchTab({
      url: '../index/index'
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})